﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;

namespace ShopOnline
{
    public partial class EditProfile : AdminBasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            ((AdminMaster)this.Master).SetPageTitle("Edit Profile");
        }

        protected void btnSave_OnClick(object sender, EventArgs e)
        {
            try
            {
                string selectedPage = ddlPages.SelectedValue;
                if (selectedPage == "")
                {
                    return;
                }

                string fileName = Server.MapPath("~/StaticPages/" + selectedPage);
                File.WriteAllText(fileName, txtEditor.Content);
            }
            catch (Exception ex)
            {
                //lblError.Text = ex.Message + ex.StackTrace;
            }
        }

        protected void ddlPages_OnSelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                string selectedPage = ddlPages.SelectedValue;
                if (selectedPage == "")
                {
                    txtEditor.Content = "";
                    return;
                }

                string fileName = Server.MapPath("~/StaticPages/" + selectedPage);
                if (File.Exists(fileName))
                {
                    txtEditor.Content = File.ReadAllText(fileName);
                }
            }
            catch (Exception ex)
            {
                //lblError.Text = ex.Message + ex.StackTrace;
            }
        }
    }
}